home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / END.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  17KB  |  711 lines

  1. /*    SCCS Id: @(#)end.c    3.0    88/05/03
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #define MONATTK_H    /* comment line for pre-compiled headers */
  6. #define NEED_VARARGS    /* comment line for pre-compiled headers */
  7. /* block some unused #defines to avoid overloading some cpp's */
  8.  
  9. #include "hack.h"
  10. #ifndef NO_SIGNAL
  11. #include <signal.h>
  12. #endif
  13.  
  14. #include "eshk.h"
  15.  
  16. void NDECL(end_box_display);
  17. STATIC_PTR int NDECL(done_intr);
  18. static void FDECL(disclose,(int,BOOLEAN_P));
  19.  
  20. static const char NEARDATA *deaths[] = {        /* the array of death */
  21.     "died", "choked", "poisoned", "starvation", "drowning",
  22.     "burning", "crushed", "turned to stone", "genocided",
  23.     "panic", "trickery",
  24.     "quit", "escaped", "ascended" };
  25.  
  26. static const char NEARDATA *ends[] = {        /* "when you..." */
  27.     "died", "choked", "were poisoned", "starved", "drowned",
  28.     "burned", "were crushed", "turned to stone", "were genocided",
  29.     "panicked", "were tricked",
  30.     "quit", "escaped", "ascended" };
  31.  
  32. int
  33. done1()
  34. {
  35. #ifndef NO_SIGNAL
  36.     (void) signal(SIGINT,SIG_IGN);
  37. #endif
  38.     if(flags.ignintr) {
  39. #ifndef NO_SIGNAL
  40.         (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  41. #endif
  42.         clrlin();
  43.         curs_on_u();
  44.         (void) fflush(stdout);
  45.         if(multi > 0) nomul(0);
  46.         return 0;
  47.     }
  48.     return done2();
  49. }
  50.  
  51. int
  52. done2()
  53. {
  54. #ifdef MACOS
  55.     if(!flags.silent) SysBeep(1);
  56.     if(UseMacAlert(128) != 1) {
  57. #else
  58.     pline("Really quit? ");
  59.     if(yn() == 'n') {
  60. #endif
  61. #ifndef NO_SIGNAL
  62.         (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  63. #endif
  64.         clrlin();
  65.         curs_on_u();
  66.         (void) fflush(stdout);
  67.         if(multi > 0) nomul(0);
  68.         multi = 0;
  69.         return 0;
  70.     }
  71. #if defined(WIZARD) && (defined(UNIX) || defined(VMS) || defined(LATTICE))
  72.     if(wizard) {
  73. # ifdef VMS
  74.         pline("Enter debugger? ");
  75. # else
  76. #  ifdef LATTICE
  77.         pline("Create SnapShot? ");
  78. #  else
  79.         pline("Dump core? ");
  80. #  endif
  81. # endif
  82. /* KL - do I need to change the next 3 lines? */
  83.         if(yn() == 'y') {
  84.         (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  85.         settty(NULL);
  86. #ifdef AMIGA
  87.         Abort(0);
  88. #else
  89. # ifdef SYSV
  90.         (void)
  91. # endif
  92.             abort();
  93. #endif
  94.         }
  95.     }
  96. #endif
  97. #ifndef LINT
  98.     done(QUIT);
  99. #endif
  100.     return 0;
  101. }
  102.  
  103. STATIC_PTR
  104. int
  105. done_intr(){
  106.     done_stopprint++;
  107. #ifndef NO_SIGNAL
  108.     (void) signal(SIGINT, SIG_IGN);
  109. # if defined(UNIX) || defined(VMS)
  110.     (void) signal(SIGQUIT, SIG_IGN);
  111. # endif
  112. #endif /* NO_SIGNAL /* */
  113.     return 0;
  114. }
  115.  
  116. #if defined(UNIX) || defined(VMS)
  117. static
  118. int
  119. done_hangup(){
  120.     done_hup++;
  121.     (void)signal(SIGHUP, SIG_IGN);
  122.     (void)done_intr();
  123.     return 0;
  124. }
  125. #endif
  126.  
  127. void
  128. done_in_by(mtmp)
  129. register struct monst *mtmp;
  130. {
  131.     char buf[BUFSZ];
  132.  
  133.     You("die...");
  134.     buf[0] = '\0';
  135.     if (mtmp->iswiz) {
  136.         Strcat(buf, "the ");
  137.         killer_format = KILLED_BY;
  138.     }
  139.     if (mtmp->minvis)
  140.         Strcat(buf, "invisible ");
  141.     if (Hallucination)
  142.         Strcat(buf, "hallucinogen-distorted ");
  143.  
  144.     if(mtmp->data->mlet == S_GHOST) {
  145.         register char *gn = (char *) mtmp->mextra;
  146.         if (!Hallucination && !mtmp->minvis && *gn) {
  147.             Strcat(buf, "the ");
  148.             killer_format = KILLED_BY;
  149.         }
  150.         Sprintf(eos(buf), (*gn ? "ghost of %s" : "ghost%s"), gn);
  151.     } else if(mtmp->isshk) {
  152.         Sprintf(eos(buf), "%s %s, the shopkeeper",
  153.             (ESHK(mtmp)->ismale ? "Mr." : "Ms."), shkname(mtmp));
  154.         killer_format = KILLED_BY;
  155.     } else Strcat(buf, mtmp->data->mname);
  156.     if (mtmp->mnamelth) Sprintf(eos(buf), " called %s", NAME(mtmp));
  157.     killer = buf;
  158.     if (mtmp->data->mlet == S_WRAITH)
  159.         u.ugrave_arise = PM_WRAITH;
  160.     else if (mtmp->data->mlet == S_MUMMY)
  161.         u.ugrave_arise = (pl_character[0]=='E') ?
  162.                         PM_ELF_MUMMY : PM_HUMAN_MUMMY;
  163.     else if (mtmp->data->mlet == S_VAMPIRE)
  164.         u.ugrave_arise = PM_VAMPIRE;
  165.     if (u.ugrave_arise > -1 && (mons[u.ugrave_arise].geno & G_GENOD))
  166.         u.ugrave_arise = -1;
  167.     if (mtmp->data->mlet == S_COCKATRICE)
  168.         done(STONING);
  169.     else
  170.         done(DIED);
  171.     return;
  172. }
  173.  
  174. /*VARARGS1*/
  175. boolean panicking;
  176. extern boolean hu;    /* from save.c */
  177.  
  178. void
  179. panic VA_DECL(const char *, str)
  180.     VA_START(str);
  181.     VA_INIT(str, char *);
  182.  
  183.     if(panicking++)
  184. #ifdef AMIGA
  185.         Abort(0);
  186. #else
  187. # ifdef SYSV
  188.         (void)
  189. # endif
  190.         abort();    /* avoid loops - this should never happen*/
  191.                     /* was exit(1) */
  192. #endif
  193.     home(); cls();
  194.     (void) puts(" Suddenly, the dungeon collapses.");
  195. #if defined(WIZARD) && !defined(MSDOS)
  196.     if(!wizard) {
  197.         pline("Report error to %s and it may be possible to rebuild.",
  198. # ifdef WIZARD_NAME    /*(KR1ED)*/
  199.         WIZARD_NAME);
  200. # else
  201.         WIZARD);
  202. # endif
  203.         more();
  204.     }
  205. #ifdef VMS
  206.     {
  207.         char *sem = rindex(SAVEF, ';');
  208.  
  209.         if (sem)
  210.             *sem = '\0';
  211.     }
  212.     Strcat(SAVEF, ".e;1");
  213. #else
  214.     Strcat(SAVEF, ".e");
  215. #endif
  216.     hu = FALSE;
  217.     (void) dosave0();
  218. #endif
  219. #ifdef MACOS
  220.     puts(" ERROR:  ");
  221. #else
  222.     (void) fputs(" ERROR:  ", stdout);
  223. #endif
  224. #ifdef LATTICE
  225.     {
  226.     char pbuf[100];
  227.     vsprintf(pbuf,str,VA_ARGS);
  228.     (void)puts(pbuf);
  229.     }
  230. #else
  231.     Vprintf(str,VA_ARGS);
  232. #endif
  233.     more();                /* contains a fflush() */
  234. #if defined(WIZARD) && (defined(UNIX) || defined(VMS) || defined(LATTICE))
  235.     if (wizard)
  236. # ifdef AMIGA
  237.         Abort(0);
  238. # else
  239. #  ifdef SYSV
  240.         (void)
  241. #  endif
  242.             abort();    /* generate core dump */
  243. # endif
  244. #endif
  245.     VA_END();
  246.     done(PANICKED);
  247. }
  248.  
  249. static void
  250. disclose(how,taken)
  251. int how;
  252. boolean taken;
  253. {
  254. #ifdef MACOS
  255.     int see_c;
  256.     char mac_buf[80];
  257. #endif
  258.     char    c;
  259.  
  260.     if(invent) {
  261. #ifndef MACOS
  262.         if(taken)
  263.         pline("Do you want to see what you had when you %s? ",
  264.             (how == QUIT) ? "quit" : "died");
  265.         else
  266.         pline("Do you want your possessions identified? ");
  267.         if ((c = yn_function(ynqchars,'y')) == 'y') {
  268. #else
  269.         {
  270.             extern short macflags;
  271.         
  272.             /* stop user from using menus, etc. */
  273.             macflags &= ~(fDoNonKeyEvt | fDoUpdate);
  274.         }
  275.         if(taken)
  276.         Sprintf(mac_buf, "Do you want to see what you had when you %s? ",
  277.             (how == QUIT) ? "quit" : "died");
  278.         else
  279.         Sprintf(mac_buf, "Do you want your possessions identified? ");
  280.         if(!flags.silent) SysBeep(1);
  281.         if ((c = "qqynq"[UseMacAlertText(129,mac_buf)+1]) == 'y') {
  282. #endif
  283.         /* New dump format by maartenj@cs.vu.nl */
  284.         struct obj *obj;
  285.  
  286.         for(obj = invent; obj && !done_stopprint; obj = obj->nobj) {
  287.             makeknown(obj->otyp);
  288.             obj->known = obj->bknown = obj->dknown = 1;
  289.         }
  290.         doinv(NULL);
  291.         end_box_display();
  292.         }
  293.         if (c == 'q')  done_stopprint++;
  294.         if (taken) {
  295.         /* paybill has already given the inventory locations 
  296.          * in the shop and put it on the main object list
  297.          */
  298.         struct obj *obj;
  299.  
  300.         for(obj = invent; obj; obj = obj->nobj) {
  301.             obj->owornmask = 0;
  302.             if(rn2(5)) curse(obj);
  303.         }
  304.             invent = (struct obj *) 0;
  305.         }
  306.     }
  307.  
  308.     if (!done_stopprint) {
  309. #ifdef MACOS
  310.         c = "qqynq"[UseMacAlertText(129, "Do you want to see your instrinsics ?")+1];
  311. #else
  312.         pline("Do you want to see your intrinsics? ");
  313.         c = yn_function(ynqchars, 'y');
  314. #endif
  315.         if (c == 'y') enlightenment();
  316.         if (c == 'q') done_stopprint++;
  317.     }
  318.  
  319. }
  320.  
  321. /* Be careful not to call panic from here! */
  322. void
  323. done(how)
  324. int how;
  325. {
  326.     struct permonst *upmon;
  327.     boolean taken;
  328.     char kilbuf[BUFSZ], buf2[BUFSZ];
  329.     /* kilbuf: used to copy killer in case it comes from something like
  330.      *    xname(), which would otherwise get overwritten when we call
  331.      *    xname() when listing possessions
  332.      * buf2: same as player name, except it is capitalized
  333.      */
  334. #ifdef ENDGAME
  335.     if (how == ASCENDED)
  336.         killer_format = NO_KILLER_PREFIX;
  337. #endif
  338.     /* Avoid killed by "a" burning or "a" starvation */
  339.     if (!killer && (how == STARVING || how == BURNING))
  340.         killer_format = KILLED_BY;
  341.     Strcpy(kilbuf, (!killer || how >= PANICKED ? deaths[how] : killer));
  342.     killer = kilbuf;
  343. #ifdef WIZARD
  344.     if (wizard && how == TRICKED) {
  345.         You("are a very tricky wizard, it seems.");
  346.         return;
  347.     }
  348. #endif
  349.     if(Lifesaved && how <= GENOCIDED) {
  350.         u.uswldtim = 0;
  351.         if(u.uhpmax < 0) u.uhpmax = 10;    /* arbitrary */
  352.         u.uhp = u.uhpmax;
  353.         adjattrib(A_CON, -1, TRUE);
  354.         pline("But wait...");
  355.         makeknown(AMULET_OF_LIFE_SAVING);
  356.         Your("medallion %s!",
  357.               !Blind ? "begins to glow" : "feels warm");
  358.         You("feel much better!");
  359.         pline("The medallion crumbles to dust!");
  360.         useup(uamul);
  361.         if (u.uhunger < 500) u.uhunger = 500;
  362.         nomovemsg = "You survived that attempt on your life.";
  363.         curs_on_u();
  364.         flags.move = 0;
  365.         if(multi > 0) multi = 0; else multi = -1;
  366.         flags.botl = 1;
  367.         u.ugrave_arise = -1;
  368.         if (how == GENOCIDED)
  369.             pline("Unfortunately you are still genocided...");
  370.         else {
  371.             killer = 0;
  372.             return;
  373.         }
  374.     }
  375. #if defined(WIZARD) || defined(EXPLORE_MODE)
  376.     if((wizard || discover) && how <= GENOCIDED) {
  377.         pline("Die? ");
  378.         if(yn() == 'y') goto die;
  379.         u.uswldtim = 0;
  380.         if(u.uhpmax < 0) u.uhpmax = 100;    /* arbitrary */
  381.         u.uhp = u.uhpmax;
  382.         if (u.uhunger < 500) u.uhunger = 500;
  383.         pline("Ok, so you don't die.");
  384.         nomovemsg = "You survived that attempt on your life.";
  385.         curs_on_u();
  386.         flags.move = 0;
  387.         if(multi > 0) multi = 0; else multi = -1;
  388.         flags.botl = 1;
  389.         u.ugrave_arise = -1;
  390.         killer = 0;
  391.         return;
  392.     }
  393. #endif /* WIZARD || EXPLORE_MODE */
  394. die:
  395. #ifndef NO_SIGNAL
  396.     (void) signal(SIGINT, (SIG_RET_TYPE) done_intr);
  397. # if defined(UNIX) || defined(VMS)
  398.     (void) signal(SIGQUIT, (SIG_RET_TYPE) done_intr);
  399.     (void) signal(SIGHUP, (SIG_RET_TYPE) done_hangup);
  400. # endif
  401. #endif /* NO_SIGNAL /* */
  402.     upmon = player_mon();
  403.     if(u.ugrave_arise > -1) /* create no corpse */ ;
  404.     else if(how == STONED)
  405.         (mk_named_object(STATUE, upmon, u.ux, u.uy, plname,
  406.                     strlen(plname)))->spe = 0;
  407. /*
  408.  * If you're burned to a crisp, why leave a corpse?
  409.  */
  410.     else if (how != BURNING)
  411.         (void) mk_named_object(CORPSE, upmon, u.ux, u.uy, plname,
  412.                             strlen(plname));
  413.  
  414.     if (how == QUIT) {
  415.         killer_format = NO_KILLER_PREFIX;
  416.         if (u.uhp < 1) {
  417.             how = DIED;
  418. /* note that killer is pointing at kilbuf */
  419.             Strcpy(kilbuf, "quit while already on Charon's boat");
  420.         }
  421.     }
  422.     if (how == ESCAPED || how == PANICKED)
  423.         killer_format = NO_KILLER_PREFIX;
  424.  
  425.     /* paybill() must be called unconditionally, or strange things will
  426.      * happen to bones levels */
  427.     taken = paybill();
  428.     paygd();
  429.     clearlocks();
  430.     if(flags.toplin == 1) more();
  431.  
  432.     disclose(how,taken);
  433.  
  434.     if(how < GENOCIDED) {
  435. #ifdef WIZARD
  436.         if(wizard) {
  437. #ifdef MACOS
  438.         if(!flags.silent) SysBeep(20);
  439.         if(UseMacAlertText(128, "Save bones ?") == 1) savebones();
  440. #else
  441.         pline("Save bones? ");
  442.         if(yn() == 'y') savebones();
  443. #endif
  444.         }  else
  445. #endif
  446.         if (how != PANICKED && how !=TRICKED)
  447.             savebones();
  448.         if(!flags.notombstone) outrip();
  449.     }
  450.  
  451. /* changing kilbuf really changes killer. we do it this way because
  452.    killer is declared a (const char *)
  453. */
  454.     if(u.uhave_amulet) Strcat(kilbuf, " (with the Amulet)");
  455.     settty(NULL);    /* does a clear_screen() */
  456.     Strcpy(buf2, plname);
  457.     if('a' <= buf2[0] && buf2[0] <= 'z') buf2[0] += 'A'-'a';
  458.     if(!done_stopprint)
  459.         Printf("Goodbye %s the %s...\n\n", buf2,
  460. #ifdef ENDGAME
  461.            how != ASCENDED ? (const char *)pl_character :
  462.            flags.female ? (const char *)"Demigoddess" : 
  463.             (const char *)"Demigod");
  464. #else
  465.            pl_character);
  466. #endif
  467.     { long int tmp;
  468.       tmp = u.ugold - u.ugold0;
  469.       if(tmp < 0)
  470.         tmp = 0;
  471.       if(how < PANICKED)
  472.         tmp -= tmp/10;
  473.       u.urexp += tmp;
  474.       u.urexp += 50 * maxdlevel;
  475.       if(maxdlevel > 20)
  476.         u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20);
  477. #ifdef ENDGAME
  478.       if(how == ASCENDED) u.urexp *= 2;
  479. #endif
  480.     }
  481.     if(how == ESCAPED
  482. #ifdef ENDGAME
  483.             || how == ASCENDED
  484. #endif
  485.                     ) {
  486.         register struct monst *mtmp;
  487.         register struct obj *otmp, *otmp2, *prevobj;
  488.         struct obj *jewels = (struct obj *)0;
  489.         long i;
  490.         register unsigned int worthlessct = 0;
  491. #if defined(LINT) || defined(__GNULINT__)
  492.         prevobj = (struct obj *)0;
  493. #endif
  494.  
  495.         /* put items that count into jewels chain
  496.          * rewriting the fcobj and invent chains here is safe,
  497.          * as they'll never be used again
  498.          */
  499.         for(otmp = fcobj; otmp; otmp = otmp2) {
  500.             otmp2 = otmp->nobj;
  501.             if(carried(otmp->cobj)
  502.                     && ((otmp->olet == GEM_SYM &&
  503.                          otmp->otyp < LUCKSTONE)
  504.                         || otmp->olet == AMULET_SYM)) {
  505.                 if(otmp == fcobj)
  506.                     fcobj = otmp->nobj;
  507.                 else
  508.                     prevobj->nobj = otmp->nobj;
  509.                 otmp->nobj = jewels;
  510.                 jewels = otmp;
  511.             } else
  512.                 prevobj = otmp;
  513.         }
  514.         for(otmp = invent; otmp; otmp = otmp2) {
  515.             otmp2 = otmp->nobj;
  516.             if((otmp->olet == GEM_SYM && otmp->otyp < LUCKSTONE)
  517.                         || otmp->olet == AMULET_SYM) {
  518.                 if(otmp == invent)
  519.                     invent = otmp->nobj;
  520.                 else
  521.                     prevobj->nobj = otmp->nobj;
  522.                 otmp->nobj = jewels;
  523.                 jewels = otmp;
  524.             } else
  525.                 prevobj = otmp;
  526.         }
  527.  
  528.         /* add points for jewels */
  529.         for(otmp = jewels; otmp; otmp = otmp->nobj) {
  530.             if(otmp->olet == GEM_SYM)
  531.                 u.urexp += (long) otmp->quan *
  532.                         objects[otmp->otyp].g_val;
  533.             else     /* amulet */
  534.                 u.urexp += (otmp->spe < 0) ? 2 :
  535.                     otmp->otyp == AMULET_OF_YENDOR ?
  536.                             5000 : 500;
  537.         }
  538.  
  539.         keepdogs();
  540.         mtmp = mydogs;
  541.         if(mtmp) {
  542.             if(!done_stopprint) Printf("You");
  543.             while(mtmp) {
  544.                 if(!done_stopprint)
  545.                     Printf(" and %s", mon_nam(mtmp));
  546.                 if(mtmp->mtame)
  547.                     u.urexp += mtmp->mhp;
  548.                 mtmp = mtmp->nmon;
  549.             }
  550.             if(!done_stopprint)
  551. #ifdef ENDGAME
  552.             Printf("\n%s with %ld points,\n",
  553.             how==ASCENDED ? "went to your reward"
  554.                 : "escaped from the dungeon",
  555. #else
  556.             Printf("\nescaped from the dungeon with %ld points,\n",
  557. #endif
  558.             u.urexp);
  559.         } else
  560.         if(!done_stopprint)
  561. #ifdef ENDGAME
  562.           Printf("You %s with %ld points,\n",
  563.             how==ASCENDED ? "went to your reward"
  564.                 : "escaped from the dungeon",
  565. #else
  566.           Printf("You escaped from the dungeon with %ld points,\n",
  567. #endif
  568.             u.urexp);
  569.  
  570.         /* print jewels chain here */
  571.         for(otmp = jewels; otmp; otmp = otmp->nobj) {
  572.             makeknown(otmp->otyp);
  573.             if(otmp->olet == GEM_SYM && otmp->otyp < LUCKSTONE) {
  574.                 i = (long) otmp->quan *
  575.                     objects[otmp->otyp].g_val;
  576.                 if(i == 0) {
  577.                     worthlessct += otmp->quan;
  578.                     continue;
  579.                 }
  580.                 Printf("        %s (worth %ld zorkmids),\n",
  581.                     doname(otmp), i);
  582.             } else {        /* amulet */
  583.                 otmp->known = 1;
  584.                 i = (otmp->spe < 0) ? 2 :
  585.                     otmp->otyp == AMULET_OF_YENDOR ?
  586.                             5000 : 500;
  587.                 Printf("        %s (worth %ld zorkmids),\n",
  588.                     doname(otmp), i);
  589.             }
  590.         }
  591.         if(worthlessct)
  592.           Printf("        %u worthless piece%s of colored glass,\n",
  593.             worthlessct, plur((long)worthlessct));
  594.     } else
  595.         if(!done_stopprint) {
  596.             Printf("You %s ", ends[how]);
  597. #ifdef ENDGAME
  598.             if (how != ASCENDED) {
  599.             if(dlevel == ENDLEVEL)
  600.                  Printf("in the endgame ");
  601.             else Printf("on dungeon level %d ", dlevel);
  602.             }
  603. #else
  604.             Printf("on dungeon level %d ", dlevel);
  605. #endif
  606.             Printf("with %ld points,\n", u.urexp);
  607.         }
  608.     if(!done_stopprint)
  609.       Printf("and %ld piece%s of gold, after %ld move%s.\n",
  610.         u.ugold, plur(u.ugold), moves, plur(moves));
  611.     if(!done_stopprint)
  612.   Printf("You were level %u with a maximum of %d hit points when you %s.\n",
  613.         u.ulevel, u.uhpmax, ends[how]);
  614. #if (defined(WIZARD) || defined(EXPLORE_MODE))
  615. # ifndef LOGFILE
  616.     if(wizard || discover)
  617.         Printf("\nSince you were in %s mode, the score list \
  618. will not be checked.\n", wizard ? "wizard" : "discover");
  619.     else
  620. # endif
  621. #endif
  622.     {
  623.         if (!done_stopprint) {
  624.             getret();
  625.             cls();
  626.         }
  627. /* "So when I die, the first thing I will see in Heaven is a score list?" */
  628.         topten(how);
  629.     }
  630.     if(done_stopprint) Printf("\n\n");
  631. #if defined(APOLLO) || defined(MACOS)
  632.     getret();
  633. #endif
  634.     exit(0);
  635. }
  636.  
  637. void
  638. clearlocks(){
  639. #if defined(DGK)
  640.     eraseall(levels, alllevels);
  641.     if (ramdisk)
  642.         eraseall(permbones, alllevels);
  643. #else
  644. # if defined(UNIX) || defined(MSDOS) || defined(VMS) || defined(MACOS)
  645.     register int x;
  646. #  if defined(UNIX) || defined(VMS)
  647.     (void) signal(SIGHUP,SIG_IGN);
  648. #  endif
  649. #  ifdef MACOS
  650.     Str255 fileName;
  651.     int oldVolume;
  652.     struct term_info *t;
  653.     extern WindowPtr HackWindow;
  654.  
  655.     t = (term_info *)GetWRefCon(HackWindow);
  656.     (void)GetVol(&fileName, &oldVolume);
  657.     (void)SetVol(0L, t->system.sysVRefNum);
  658. #  endif
  659.     for(x = maxdlevel; x >= 0; x--) {
  660.         glo(x);
  661.         (void) unlink(lock);    /* not all levels need be present */
  662.     }
  663. #  ifdef MACOS
  664.     (void)SetVol(0L, oldVolume);
  665. #  endif
  666. # endif
  667. #endif
  668. }
  669.  
  670. #ifdef NOSAVEONHANGUP
  671. int
  672. hangup()
  673. {
  674.     (void) signal(SIGINT, SIG_IGN);
  675.     clearlocks();
  676. # ifndef VMS
  677.     exit(1);
  678. # endif
  679. }
  680. #endif
  681.  
  682. void
  683. end_box_display()
  684. {
  685.     register struct obj *box, *obj;
  686.     char buf[BUFSZ];
  687.  
  688.     for(box=invent; box; box=box->nobj) {
  689.         if (Is_container(box) && box->otyp != BAG_OF_TRICKS) {
  690.         int cnt=0;
  691.  
  692.         for(obj=fcobj; obj; obj=obj->nobj) {
  693.             if (obj->cobj == box) {
  694.             if (!cnt) {
  695.                 Sprintf(buf, "Contents of the %s:",xname(box));
  696.                 cornline(0, buf);
  697.             }
  698.             makeknown(obj->otyp);
  699.             obj->known = obj->bknown = obj->dknown = 1;
  700.             cornline(1,doname(obj));
  701.             cnt++;
  702.             }
  703.         }
  704.         if (!cnt) {
  705.             pline("The %s is empty.", xname(box));
  706.             more();
  707.         } else cornline(2,"");
  708.         }
  709.     }
  710. }
  711.